import { Entity, Column } from "typeorm";
import { Base } from "@/entities.base/base.entity";

@Entity({ comment: '产品表', name: 'basis_products' })
export class Product extends Base {

    /** 产品编号 */
    @Column({
        comment: '产品编号',
        length: 50,
        unique: true, // 产品编号唯一
    })
    code: string;

    /** 产品名称 */
    @Column({
        comment: '产品名称',
        length: 100,
    })
    name: string;

    /** 产品分类 */
    @Column({
        comment: '产品分类',
        length: 50,
        nullable: true,
    })
    category?: string;

    /** 产品品牌 */
    @Column({
        comment: '产品品牌',
        length: 50,
        nullable: true,
    })
    brand?: string;

    /** 产品规格 */
    @Column({
        comment: '产品规格',
        length: 100,
        nullable: true,
    })
    specification?: string;

    /** 产品单位 */
    @Column({
        comment: '产品单位',
        length: 20,
        default: '瓶',
    })
    unit: string;

    /** 产品描述 */
    @Column({
        type: 'text',
        comment: '产品描述',
        nullable: true,
    })
    description?: string;

    /** 产品图片URL */
    @Column({
        comment: '产品图片URL',
        length: 500,
        nullable: true,
    })
    imageUrl?: string;

    /** 零售价格 */
    @Column({
        comment: '零售价格',
        type: 'decimal',
        precision: 10,
        scale: 2,
        default: 0,
    })
    retailPrice: number;

    /** 会员价格 */
    @Column({
        comment: '会员价格',
        type: 'decimal',
        precision: 10,
        scale: 2,
        nullable: true,
    })
    memberPrice?: number;

    /** 成本价格 */
    @Column({
        comment: '成本价格',
        type: 'decimal',
        precision: 10,
        scale: 2,
        nullable: true,
    })
    costPrice?: number;

    /** 赠送积分 */
    @Column({
        comment: '赠送积分',
        type: 'int',
        default: 0,
    })
    giftPoints?: number;

    /** 当前库存数量 */
    @Column({
        comment: '当前库存数量',
        type: 'int',
        default: 0,
    })
    stockQuantity: number;

    /** 库存预警数量 */
    @Column({
        comment: '库存预警数量',
        type: 'int',
        default: 10,
    })
    warningQuantity: number;

    /** 产品状态 */
    @Column({
        comment: '产品状态',
        length: 20,
        default: 'active',
    })
    status: string;

    /** 是否推荐 */
    @Column({
        comment: '是否推荐',
        type: 'boolean',
        default: false,
    })
    isRecommended: boolean;

    /** 产品标签 */
    @Column({
        comment: '产品标签',
        length: 200,
        nullable: true,
    })
    tags?: string;
} 